
var binary = 0;
var guide = 0;
var ul = document.getElementById("m1ul");
var uid;

mui('body').on('tap','#m1a1',function(){
	if(uid==0) binary=1;
	else binary=0;
	guide = 0;
	loadData('0');
})

function loadData(nums)
{
	if(nums=='0')
	{
		ul.innerHTML = "";
	}
	
	uid = localStorage.getItem("uid");
	if(uid==null||uid=='')
	{
		uid = 0;
		binary = 1;
		guide = 0;
	}
	
	mui.ajax({
		url :ASYURI+'A1010.do',
		data:{
			'binary':binary,
			'guide' :guide,
			'uid'   :uid,
		},
		dataType:'JSON',
		type:'post',
		timeout:10000,
		success:function(data){
			var edata = eval('('+data+')');
			var length = edata.length;
			for(var i=0;i<length-1;i++)
			{
				var sin = edata[i];
				var li = liInit();
				var a = aInit(sin.A1010,sin.A1011);
				
				li.appendChild(a);
				ul.appendChild(li);
			}
			var sin = edata[length-1];
			binary = sin.binary;
			guide = parseInt(sin.guide) + parseInt(guide);
			if(parseInt(sin.guide)==0) mui.toast("您已经翻到底啦！");
		},
		error:function(xhr,type,errorThrown){
			console.log(xhr+":"+type+"-"+errorThrown);
		}
	});
}

function liInit()
{
	var li = document.createElement("li");
	li.setAttribute("class","mui-table-view-cell");
	return li;
}
function aInit(aI1,aI2)
{
	var a = document.createElement("a");
	a.innerHTML= aI2;
	a.setAttribute("class","mui-navigate-right");
	a.setAttribute("onclick","openPage('"+aI1+"','"+aI2+"')");
	return a;
}

function openPage(qid,title)
{
	localStorage.setItem("m101qid",qid);
	localStorage.setItem("m101title",title);
	mui.openWindow("m101.html");
}

mui("body").on("tap","#m1a2",function(){
	loadData("1");
});

loadData('0');

